﻿using System;
using System.IO;
using UploadClient.Interfaces;

namespace UploadClient.Utilitys
{
    public class UploadItem : IUploadItem
    {
        /// <summary>
        /// The path of the file.
        /// <example>C:\\path\file.txt</example>
        /// </summary>
        private string _Filepath;

        #region IUploadItem Members

        /// <summary>
        /// GUID from UploadProvider.
        /// </summary>
        public Guid UploadType { get; set; }

        /// <summary>
        /// Settings to connect to the server.
        /// </summary>
        public IServerSettings ServerSettings { get; set; }

        /// <summary>
        /// The filename of the file.
        /// </summary>
        public string Filename { get; private set; }

        /// <summary>
        /// The extension of the file.
        /// <example>txt/jpg/zip/..</example>
        /// </summary>
        public string Extension { get; private set; }

        public string Filepath 
        {
            get
            {
                return _Filepath;
            }
            set
            {
                try
                {
                    Extension = Path.GetExtension(value);
                    Filename = Path.GetFileNameWithoutExtension(value);
                    _Filepath = value;
                }
                catch
                {
                    _Filepath = string.Empty;
                }
            }
        }

        #endregion
    }
}
